package com.dmgis.qxfw.dataservice.gisservice.controller;


import com.dmgis.entity.DmMapPoint;
import com.dmgis.qxfw.dataservice.gisservice.service.ITransformService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/*投影变换服务*/
@Controller
@RequestMapping("/transform")
public class CoordTransform {

    @Resource
    private ITransformService transformService;
    @RequestMapping("GeotoLb")
    @ResponseBody
    public Object LonLatConvertToLambert(HttpServletRequest request){
        //加载类库
        System.loadLibrary("dmJavaLib");
        String x = request.getParameter("x");
        String y = request.getParameter("y");
        double x1 = Double.parseDouble(x);
        double y1 = Double.parseDouble(y);
        DmMapPoint dot = transformService.LonLatConvertToLambert(x1,y1);
        return dot;
    }
    @RequestMapping("LbtoGeo")
    @ResponseBody
    public Object LambertConvertToLonLat(HttpServletRequest request){
        System.out.println(System.getProperty("java.library.path"));
        System.loadLibrary("dmJavaLib");
        String x=request.getParameter("x");
        String y=request.getParameter("y");
        double x1 = Double.parseDouble(x);
        double y1 = Double.parseDouble(y);
        DmMapPoint dot= transformService.LambertConvertToLonLat(x1,y1);
        return  dot;
    }

    @RequestMapping("GeotoMkt")
    @ResponseBody
    public Object LonLatConvertToMercator(HttpServletRequest request){
        System.out.println(System.getProperty("java.library.path"));
        System.loadLibrary("dmJavaLib");
        String x=request.getParameter("x");
        String y=request.getParameter("y");
        double x1 = Double.parseDouble(x);
        double y1 = Double.parseDouble(y);
        DmMapPoint dot=transformService.LonLatConvertToMercator(x1,y1);
        return dot;
    }

    @RequestMapping("MkttoGeo")
    @ResponseBody
    public Object MercatorConvertToLonLat(HttpServletRequest request){
        System.out.println(System.getProperty("java.library.path"));
        System.loadLibrary("dmJavaLib");
        String x=request.getParameter("x");
        String y=request.getParameter("y");
        double x1 = Double.parseDouble(x);
        double y1 = Double.parseDouble(y);
        DmMapPoint dot=transformService.MercatorConvertToLonLat(x1,y1);
        return dot;
    }
}
